# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=mediastreamer2
pkgver=5.2.86
pkgrel=0
pkgdesc="library written in C that allows you to create and run audio and video streams"
url="https://www.linphone.org/technical-corner/mediastreamer2"
arch="all"
license="GPL-2.0-or-later"
options="!check" # no test available
makedepends="
	alsa-lib-dev
	bcg729-dev
	bctoolbox-dev
	bzrtp-dev
	cmake
	doxygen
	ffmpeg4-dev
	gettext-dev
	glew-dev
	graphviz
	grep
	gsm-dev
	jpeg-dev
	libpcap-dev
	libsrtp-dev
	libtheora-dev
	libvpx-dev
	libxml2-dev
	libxv-dev
	mesa-dev
	opus-dev
	ortp-dev
	python3-dev
	samurai
	spandsp-dev
	speex-dev
	speexdsp-dev
	sqlite-dev
	tiff-dev
	v4l-utils-dev
	"
subpackages="$pkgname-dev $pkgname-doc"
source="https://gitlab.linphone.org/BC/public/mediastreamer2/-/archive/$pkgver/mediastreamer2-$pkgver.tar.gz
	missing-def-o-binary.patch"

build() {
	cmake -G Ninja -B build \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_MODULE_PATH=/usr/lib/cmake \
		-DCMAKE_SKIP_INSTALL_RPATH=ON \
		-DENABLE_STRICT=NO \
		-DENABLE_ALSA=YES \
		-DENABLE_STATIC=NO \
		-DENABLE_RESAMPLE=YES \
		-DENABLE_JPEG=YES \
		-DENABLE_PCAP=YES \
		-DENABLE_FFMPEG=YES \
		-DENABLE_SPEEX_CODEC=YES \
		-DENABLE_SPEEX_DSP=YES \
		-DENABLE_SHARED=YES \
		-DENABLE_VPX=YES \
		-DENABLE_UNIT_TESTS=NO
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	rm -r "$pkgdir"/usr/include/OpenGL
}

dev() {
	default_dev
	mkdir -p "$subpkgdir"/usr/lib/cmake/Mediastreamer2
	mv "$pkgdir"/usr/share/Mediastreamer2/cmake/* "$subpkgdir"/usr/lib/cmake/Mediastreamer2
	# Remove empty dirs
	rmdir "$pkgdir"/usr/share/Mediastreamer2/cmake
	rmdir "$pkgdir"/usr/share/Mediastreamer2
}

sha512sums="
6f6e6f4f6b9a20c95d359ae7410c31478968e5c10b77e73b5c5ca5daa1c01a8a17713d69b9713102621b35aa6b603def0dfe1122a6393917b76ff1abbed2a62c  mediastreamer2-5.2.86.tar.gz
d0158e03a7552580a9d9f04226c18a31a23d3cc502d52b51a9b083a5c32094ea7349495a7f74316eb727c2478a80b0385e1a28798b5b7d6e85e463485e33a822  missing-def-o-binary.patch
"
